<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<load href="__PUBLIC__/Css/css.css" />
<load href="__PUBLIC__/Js/jquery-1.10.2.min.js"/>
<load href="__PUBLIC__/Js/jquery-1.8.3.min.js"/>
<title>帖子内容</title>
</head>

<body>

<div id="wapper">
	<div class="header">
		<div class="kuang">
			<div class="type">
				<ul>
					<li><a href="{:U('Message/tiezi',array('class' => '生活类'))}" target="_blank">生活类</a></li>
					<li><a href="{:U('Message/tiezi',array('class' => '学习类'))}" target="_blank">学习类</a></li>
					<li><a href="{:U('Message/tiezi',array('class' => '娱乐类'))}" target="_blank">娱乐类</a></li>
					<li style="border:none"><a href="{:U('Message/tiezi',array('class' => '时事类'))}" target="_blank">时事类</a></li>
				</ul>
			</div>
		
		</div>
			
			
	</div>
	
	<div id="index">
		<div class="kuang">
			<div class="id-ct">
			
				<div class="ourname">
				
					<h2>OUR TIPS</h2>
					<h1>我们贴吧</h1>
				    <a href="{:U('Index/index')}"><h2>返回主页</h2></a>
				</div>
			<foreach name='list' item='c'>
			<div class="login">	
					<div class="login-left">
						<div class="mylogin">
							<h2>楼主信息：</h2>
							<img src='__PUBLIC__/uploads/{$c.head}'>
							<p>{$c.username}</p>
							<?php 
							   $where['fid']=$_SESSION['uid'];
							   $where['cid']=$c['id'];
							   $f=M('Friends');
							   $fensi=$f->where($where)->find();
							   
							?>
							<?php if($fensi['fensi']==1){  ?>
			                     <a href="{:U('Friends/doCancelGz')}?cid={$c.id}" id="aaa">已关注</a>
		                    <?php }else{ ?>
		                   	<a href="{:U('Friends/doGz')}?cid={$c.id}" id="aaa">加关注</a>
		                        <?php } ?></a>
							<a href="{:U('Index/index')}?cid={$c.id}" id="aaa">加好友</a>
						</div>
					</div>
					<div class="ct-right">
						<div class="tips-tc">
							<div class="tips-detail">
								<h3>帖子题目：</h3>
								<p>{$c.title}</p>
								<h3>帖子分类：</h3>
								<p>{$c.class}</p>
								<h3>发布人：</h3>
								<p>{$c.username}</p>
								<div class="neirong">
									<span>发布内容：</span>
									<h3>发布时间：</h3>
									<p>{$c.time}</p>
									<h4>{$c.content}</h4>
<span>
<?php if($c['add']!=null){
        $dl=M('Answer');
		$where0['tid']=$c['tid'];
		$where0['fid']=$_SESSION['uid'];
		$da=$dl->where($where0)->select();
		if(empty($da) ){
		echo '请先回复！';	
		}else{?>
<p>附件名：</p><a href="__ROOT__/Public/uploads/<?php echo $c['add']; ?>"><?php echo $c['add']; ?></a><br/>
<?php }}else{?> 
没有附件
<?php }?></span>


<?php
           $user1=M('User');
           $where['id']=$_SESSION['uid'];
           $arr=$user1->where($where)->find();
           $collect=$arr['collect'];
		   $co=explode(",",$collect,-1);
		   $count=count($co);
		   $n=0;
		   for($i=0;$i<$count;$i++){
		       if($co[$i]==$c['tid']){
			     $n=1;
			   }
		   }
		   if($n==1){ ?>
		   已收藏
<?php
		   }else{ ?>
		   <a href="{:U('Message/doShou')}?tid={$c.tid}">收藏</a>
<?php
		   }
?>
	                             <a  class="replay-tips" >回复留言</a>
								</div>
							</div>
						</div>	
					</div>	 
					<form action="{:U('Message/huifu',array('tid' => $c['tid']))}" method="post" class="replay">
						<h3>回复楼主：</h3>
						<textarea name="huifu" class="replay-text"  placeholder="请输入您要回复的内容：">
						</textarea>
						<input type="submit" id="replay-bt" value="提交回复" name="replay-bt" />
					</form>				
<script type="text/javascript">	
	$(document).ready(function(){
		
		$(".replay-tips").click(function(){
		 $(this).text($(".replay").is(":hidden") ? "收起" : "回复留言");
 			 $(".replay").slideToggle(300);
	    });
	});

</script>				
				</div>					
<?php               
                     $tid = $c['tid'];
                     $where1['sid']=0; 
		             $where1['tid']=$tid;	
                    // $data2 = M('user  as  a')->join('lt_answer  as  b  on b.fid = a.id')->where($where1)->select();  
					 $count =  M('user  as  a')->join('lt_answer  as  b  on b.fid = a.id')->where($where1)->count();// 查询满足要求的总记录数
                     $Page= new \Think\Page($count,4);// 实例化分页类 传入总记录数和每页显示的记录数(25)
                     $show= $Page->show();// 分页显示输出
                     // 进行分 页数据查询 注意limit方法的参数要使用Page类的属性
                     $data2 =  M('user  as  a')->join('lt_answer  as  b  on b.fid = a.id')->where($where1)->limit($Page->firstRow.','.$Page->listRows)->select();
					 
		$x=0;		$y=0;	 
?>	
<foreach name='data2' item='c1'>	
<?php                
					 $x=$x+1;
                     $tid = $c1['tid'];
					 $where2['sid'] = array('NEQ',0);
					 $where2['fid']=$c1['fid'];
		             $where2['tid']=$tid;	
                     $data3 = M('user  as  a')->join('lt_answer  as  b  on b.sid = a.id')->where($where2)->select();                      
?>		  
			<div class="login">
				<ul class="our-reply">
					<li>
						<div class="floor">
							<div class="login-left">
								<div class="mylogin">
									<h2>{$c1.username}回复：</h2>
									<img src='__PUBLIC__/uploads/{$c1.head}'>
									<p>{$c1.name}</p>
									<?php 
							   $where['fid']=$_SESSION['uid'];
							   $where['cid']=$c['id'];
							   $f=M('Friends');
							   $fensi=$f->where($where)->find();
							   
							?>
							<?php if($fensi['fensi']==1){  ?>
			                     <a href="{:U('Friends/doCancelGz')}" id="aaa">已关注</a>
		                    <?php }else{ ?>
		                   	<a href="{:U('Friends/doGz')}" id="aaa">加关注</a>
		                        <?php } ?></a>
							<a href="{:U('Index/index')}" id="aaa">加好友</a>	
								</div>
							</div>
							<div class="ct-right">
								<div class="floor-ct">
									<h3>留言内容：</h3>
									<h4>{$c1.acontent}</h4>


<?php 
if($c['id']==$_SESSION['uid']){ ?>	
<a href="{:U('Message/dele',array('cid' => $c1['id'],'tid' => $c['tid']))}" class="replay-floor1">删除留言</a>
<a  class="replay-floor<?php echo $x; ?>" >回复留言</a>

<?php }else{ ?>
<a  class="replay-floor<?php echo $x; ?>" >回复留言</a>

<?php } ?>


									
<!-- <a  class="replay-floor<?php echo $x; ?>" >回复留言</a> -->
<form action="{:U('Message/huifu2',array('tid' => $c1[tid],'fid'=>$c1[fid]))}" method="post" class="replay2<?php echo $x; ?>">
<textarea name="huifu2" class="replay2<?php echo $x; ?>-text"  placeholder="请输入您要回复的内容："></textarea>
<input type="submit" id="floor-bt" value="提交回复" name="replay-bt" />
</form>
<style>
 .replay-floor<?php echo $x; ?>{
	 background: #fff none repeat scroll 0 0;
    border: 0 none;
    border-radius: 5px;
    box-shadow: 1px 2px 2px #ccc;
    display: block;
    float: right;
    font-size: 16px;
    height: 40px;
    line-height: 40px;
    margin-right: 34px;
    margin-top: 25px;
    text-align: center;
    width: 100px;


}

.replay-floor<?php echo $x; ?>:hover{
	background:#99cccc;
	color:#fff;
}



.replay2<?php echo $x; ?>{
    float: left;
    margin-left: 32px;
    padding-bottom: 17px;
    width: 93%;
	display:none;
}



.replay2<?php echo $x; ?>-text{
	 border:1px dashed #ccc;
    margin-top: 10px;
    max-width: 95%;
    min-height: 100%;
    min-width: 95%;
    padding: 20px;
	background:#FFFFFC;
	border-radius:3px;

}
</style>
<script type="text/javascript">	
	$(document).ready(function(){
		$(".replay-floor<?php echo $x; ?>").click(function(){
		 $(this).text($(".replay2<?php echo $x; ?>").is(":hidden") ? "收起" : "回复留言");
		 $(this).siblings(".replay2<?php echo $x; ?>").slideToggle(300);
	    });
	});

</script>
<script type="text/javascript">	
	$(document).ready(function(){
		
		$(".liuyan").show();
		$(".show").click(function(){
		
		 $(this).text($(".liuyan").is(":hidden") ? "收起" : "展开留言");
		 	 $(this).siblings(".liuyan").slideToggle(300);
 			
	    });
	});

</script>	
	<style>
	.replay-floor-bottom<?php echo $y+1; ?>{
    border-top: 1px solid #ededed;
    float: left;
    margin-top: 20px;
	margin-left: 32px;
	padding:10px;

    width: 90%;

}
.show{
	 background: #f9f9f9 none repeat scroll 0 0;
    border: 1px solid #ededed;
    display: block;
    height: 40px;
    line-height: 40px;
    text-align: center;
    width: 15%;

}
.floor-bottom-ct<?php echo $y+1; ?>{
	background: #f9f9f9 none repeat scroll 0 0;
   
    overflow: hidden;
    width: 100%;
}
	</style>
	<div class="replay-floor-bottom<?php echo $y+1; ?>">
	  <a class="show">收起</a>
	<foreach name='data3' item='c2'>
<?php $y=$y+1; ?>	
	  <div class="liuyan" style=" border: 1px solid #ededed; display:none;">	
		<div class="floor-bottom-ct">
			<img src='__PUBLIC__/uploads/{$c2.head}' style="width:10%;height:10%">
			<a href="" style="color:#990000;"  >{$c2.username}</a><span>回复：</span><p>{$c2.acontent}</p><h5><?php echo date('Y-m-d',$c2['atime']); ?></h5>
		</div>
	  </div>
		</foreach>
	</div>
								</div>
							</div>
						</div>				
					</li>
				</ul>
			</div>	
</foreach>
				 <center>   {$show} </center>
				</foreach>
				</div>
			   </div>			
			</div>		
		</div>			
	</div>	
</div>
</body>
</html>
